package org.example;

import java.util.*;

/**
 * @Description: TODO
 * @Author wyatt
 * @Data 2024/02/05 11:11
 */
public class Main {

    public static void main(String[] args) {

        Properties properties = System.getProperties();
        Enumeration<?> keys  = properties.propertyNames();
        while (keys.hasMoreElements()){
            String key = (String) keys.nextElement();
            System.out.println("key : " +key + " value : " + properties.getProperty(key));
        }

        Locale locale = new Locale("US");

        String[] countryCodes = Locale.getISOCountries();
        for (int i = 0; i < countryCodes.length; i++) {
            System.out.println(countryCodes[i]);
        }



        List<Integer> appearList = new ArrayList();
        appearList.add(1);
        appearList.add(2);
        appearList.add(3);
        appearList.add(4);

        //取前三个最大的连续段
        if(appearList.size() > 3){
            appearList.sort(new Comparator<Integer>() {
                @Override
                public int compare(Integer o1, Integer o2) {
                    return o2-o1;
                }
            });
            appearList = appearList.subList(0,3);
        }
        System.out.println(appearList.size());
        System.out.println(appearList.get(0));
        System.out.println(appearList.get(1));
        System.out.println(appearList.get(2));

        Deque<Integer> queue = new ArrayDeque<>();
        queue.offerLast(0);
        print(queue);

        System.out.println(queue.peekFirst());
        System.out.println(queue.pollFirst());

        print(queue);

        queue.offerLast(1);

        print(queue);

//        for (int i = 1; i < n; i++) {
//            while (queue.peekFirst() < i - k) {
//                queue.pollFirst();
//            }
//            dp[i] = dp[queue.peekFirst()] + nums[i];
//            while (!queue.isEmpty() && dp[queue.peekLast()] <= dp[i]) {
//                queue.pollLast();
//            }
//            queue.offerLast(i);
//        }
    }

    private static void print(Deque<Integer> deque){
        if(deque.size() == 0){
            System.out.println("null");
        }
        // 使用for-each循环遍历并打印Deque中的元素
        for (Integer element : deque) {
            System.out.println(element);
        }
    }
}
